<template>
  <div>
    <el-table :data="attendance">
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="status.title" label="考勤状态"></el-table-column>

      <el-table-column label="操作">
        <template #default="{row}">
          <el-button type="warning" @click="editRow(row)">修改</el-button>
          <el-button type="danger">删除</el-button>
        </template>

      </el-table-column>

    </el-table>


    <el-dialog v-model="isVisible">

      <el-form label-width="90">
        <el-form-item label="姓名">
          <el-input v-model="current.name"></el-input>
        </el-form-item>

        <el-form-item label="出勤状态">
          <el-select>
            <el-option v-for="item in statuses" :value="item.id" :label="item.title"></el-option>
          </el-select>
        </el-form-item>
      </el-form>

    </el-dialog>

  </div>
</template>

<script>
export default {
  name: "Attendance",
  data() {
    return {
      attendance: [],
      isVisible: false,
      statuses: [],
      current: {
        name: '',
        status: {
          id: 0
        }
      }
    }
  }, mounted() {

    this.axios({
      url: 'http://test.org/status',
      method: 'get',
      dataType: 'json'
    }).then((res) => {
      this.statuses = res.data;
    })

    this.axios({
      url: 'http://test.org/attend',
      method: 'get',
      dataType: 'json'
    }).then((res) => {
      this.attendance = res.data;
      console.log(this.attendance)
    })
  }, methods: {
    editRow(row) {
      console.log(row);


      this.current.name = row.name;
      this.isVisible = true;
    }
  }
}
</script>

<style scoped>

</style>